class Solution {
public:
  vector<vector<int>> subsets(vector<int>& nums) {

    vector<vector<int>> ans;
    vector<int> temp;
    int index = 0;

    dfs(nums, 0, temp, ans);

    return ans;

  }

  void dfs(vector<int> &nums, int index, vector<int> &temp, vector<vector<int>> &ans){

    if(index >= nums.size()){
      ans.push_back(temp);
      return;
    }

    dfs(nums, index + 1, temp, ans);
    temp.push_back(nums[index]);
    dfs(nums, index + 1, temp, ans);
    temp.pop_back();

  }
};